<%--

  ING Event component.

  ING Event

--%><%
%><%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false" import="java.util.*"%><%
%><%
    String maxAttendees = properties.get("maxAttendees", "-");
    String eventName = properties.get("eventName", "Event");
    String eventDescription = properties.get("eventDescription", "-");

    String subStart = properties.get("subStart",
            "Please enter subscription start");
    String subEnd = properties.get("subEnd",
            "Please enter subscription end");

    Long startDate = 0L;
    Long endDate = 0L;
    try {
        startDate = Date.parse(subStart);
        endDate = Date.parse(subEnd);
    } catch (Exception e) {
    }
    
    boolean isOpen = false;
    
    Long current = System.currentTimeMillis();
    if (endDate != null && startDate != null && current < endDate && current > startDate){
        isOpen = true;
    }
    
    String registrationClosedMessage = properties.get("regClosedMsg", "The registration for this event is closed.");
    String registrationNotOpenMessage = properties.get("regNotOpenMsg", "The registration for this event has not yet opened.");
%>

Name:
<%=eventName%><br />
Description:
<%=eventDescription%><br />
Maximum number of attendees:
<%=maxAttendees%><br />
Registration opens on:
<%=new Date(startDate) %><br/>
Registration ends on:
<%=new Date(endDate) %><br/>
<% if (isOpen){ %>
    <p><a href="#">Register for this event</a></p>
<%}else if (current > endDate){ %>
    <p><%= registrationClosedMessage %></p>
<%}else { %>
    <p><%= registrationNotOpenMessage %></p>
<%} %>

